#include "gui.h"

bool GUI::isUsable = true;
int GUI::temp_count = 0;

GUI::GUI(QGraphicsObject *parent)
    : QGraphicsObject(parent)
{
    currGui = 0;
}

void GUI::setCurrentGui(GUI *g)
{
    prevGui = currGui;
    currGui = g;
}

void GUI::resetCurrentGui()
{
    currGui = prevGui;
}

void GUI::doSelect()
{
    if (currGui != 0) {
        currGui->select();
    }
}

void GUI::doUp()
{
    if (currGui != 0) {
        currGui->up();
    }
}

void GUI::doDown()
{
    if (currGui != 0) {
        currGui->down();
    }
}

void GUI::doLeft()
{
    if (currGui != 0) {
        currGui->left();
    }
}

void GUI::doRight()
{
    if (currGui != 0) {
        currGui->right();
    }
}

void GUI::doExchange()
{
    if (currGui != 0) {
        currGui->exchange();
    }
}

void GUI::setUsable(bool u)
{
     isUsable = u;
     if (u) {
         qDebug() << "gui is usable.";
     } else {
         qDebug() << "gui is busy, please wait.";
     }
}

void GUI::animationFinish()
{
    temp_count++;
    qDebug() << "gui: animation has just stopped, so gui is usable." << temp_count;

    this->isUsable = true;
}

QRectF GUI::boundingRect() const
{
    return QRectF();
}

void GUI::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(painter);
    Q_UNUSED(option);
    Q_UNUSED(widget);
}
